package main

import (
	log "github.com/sirupsen/logrus"
	big "math/big"

	"os"
)

func PathExists(path string) bool {
	_, err := os.Stat(path)
	if err == nil {
		return true
	}
	if os.IsNotExist(err) {
		return false
	}
	log.Errorf(" %v", err)
	return false
}

func GetFileSize(path string) (*big.Int, error) {
	fileObj, err := os.Open(path)
	if err != nil {
		log.Error(err)
	}
	fileInfo, err := fileObj.Stat()
	if err != nil {
		log.Error(err)
		return big.NewInt(int64(-1)), err
	}
	return big.NewInt(fileInfo.Size()), nil

}

func GetDirSize(path string) (*big.Int, error) {
	totalSize, err := TraversalCountDir(path)
	if err != nil {
		return big.NewInt(int64(-1)), err
	}
	return totalSize, nil

}
